﻿CREATE PROCEDURE [dbo].[proc_ContratosOpcoesRefeicaoLoadByPrimaryKey]
(
	@IdRefeicaoContratada bigint,
	@CodOpcao nvarchar(3)
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		cor.[IdRefeicaoContratada],
		cor.[CodOpcao],
		cor.[Descricao],
		cor.[DataCriacao],
		cor.[DataAlteracao],
		t.Descricao as DescricaoOpcao,
		t.DescricaoCurta as DescricaoCurtaOpcao,
		t.Simbolo as SimboloOpcao,
		t.Tipo as TipoOpcao
	FROM [ContratosOpcoesRefeicao] cor 
	    inner join Tipologias t on cor.CodOpcao = t.Codigo and t.Tipo = 'TipoOpcao'
	WHERE
		([IdRefeicaoContratada] = @IdRefeicaoContratada) AND
		([CodOpcao] = @CodOpcao)

	SET @Err = @@Error

	RETURN @Err
END
